package com.caishi.lkx.exam.records;

import com.zzw.common.mysql.MybatisPlusEnum;
import com.caishi.lkx.exam.ienum.type.PaperRecordType;
import com.caishi.lkx.exam.ienum.type.QuestionCollectionType;

public enum RecordsCollectType implements MybatisPlusEnum<String> {
    chapter, // 章节练习
    everyday, // 每日一练

    rankError, // 高频错题
    hotQue, // 热门试题
    rankCollect, // 收藏排行
    paperRecordChapterPractice, //试卷练习
    paperRecordPaperLibrary,// 试卷考试
    paperRecordSpecialPractice,// 专项练习
    paperRecordRandomFormPaper,//随机组件
    paperRecordErrorCombination, //错题组卷

    ;

    @Override
    public String getCode() {
        return name();
    }

    public static RecordsCollectType paperRecordType2Type(PaperRecordType paperRecordType) {
        if (paperRecordType == PaperRecordType.paperLibrary) {
            return RecordsCollectType.paperRecordPaperLibrary;
        }
        if (paperRecordType == PaperRecordType.randomFormPaper) {
            return RecordsCollectType.paperRecordRandomFormPaper;
        }
        if (paperRecordType == PaperRecordType.specialPractice) {
            return RecordsCollectType.paperRecordSpecialPractice;
        }
        if (paperRecordType == PaperRecordType.errorCombination) {
            return RecordsCollectType.paperRecordErrorCombination;
        }
        if (paperRecordType == PaperRecordType.chapterPractice) {
            return RecordsCollectType.paperRecordChapterPractice;
        }
        return null;
    }

    public static RecordsCollectType collectType2Type(QuestionCollectionType collectionType) {
        if (collectionType == QuestionCollectionType.chapter) {
            return RecordsCollectType.chapter;
        }
        if (collectionType == QuestionCollectionType.paper) {
            return RecordsCollectType.paperRecordChapterPractice;
        }
        if (collectionType == QuestionCollectionType.rankError) {
            return RecordsCollectType.rankError;
        }
        if (collectionType == QuestionCollectionType.hotQue) {
            return RecordsCollectType.hotQue;
        }
        if (collectionType == QuestionCollectionType.rankCollect) {
            return RecordsCollectType.rankCollect;
        }
        if (collectionType == QuestionCollectionType.everyDayPractice) {
            return RecordsCollectType.everyday;
        }
        return null;
    }
    public PaperRecordType type2PaperRecordType() {
        if (this == RecordsCollectType.paperRecordChapterPractice) {
            return PaperRecordType.chapterPractice;
        }
        if (this == RecordsCollectType.paperRecordErrorCombination) {
            return PaperRecordType.errorCombination;
        }
        if (this == RecordsCollectType.paperRecordSpecialPractice) {
            return PaperRecordType.specialPractice;
        }
        if (this == RecordsCollectType.paperRecordRandomFormPaper) {
            return PaperRecordType.randomFormPaper;
        }
        if (this == RecordsCollectType.paperRecordPaperLibrary) {
            return PaperRecordType.paperLibrary;
        }
        return null;
    }

    public QuestionCollectionType type2CollectType() {
        if (this == RecordsCollectType.chapter) return QuestionCollectionType.chapter;
        if (this == RecordsCollectType.everyday) return QuestionCollectionType.everyDayPractice;
        if (this == RecordsCollectType.rankError) return QuestionCollectionType.rankError;
        if (this == RecordsCollectType.rankCollect) return QuestionCollectionType.rankCollect;
        if (this == RecordsCollectType.hotQue) return QuestionCollectionType.hotQue;
        return QuestionCollectionType.paper;
    }

    public String staticCid(String id) {
//        var time = TimeUtil.DATE_TIME_FORMATTER_DAY_YMD.format(LocalDate.now());
        var time = "";
        if (this == RecordsCollectType.rankError) {
            return QuestionCollectionType.RANK_ERROR_ID + time;
        }
        if (this == RecordsCollectType.rankCollect) {
            return QuestionCollectionType.RANK_COLLECT_ID + time;
        }
        if (this == RecordsCollectType.hotQue) {
            return QuestionCollectionType.HOT_QUE_ID + time;
        }
        return id;
    }

}
